ColdFusion Article

Creating Globalized ColdFusion Applications


Table of Contents

  1. Introduction
  2. Globalization Changes in ColdFusion MX
  3. Good Practices: Obstacles in Developing I18N Applications
  4. Good Practices (cont): Encoding, Unicode, HTML
  5. Good Practices (cont): Locale Determination, Locale-Specific Formatting, Time Zones
  6. Good Practices (cont): ResourceBundles,Application Framework, User Specific, Server Specific

Globalization Changes in ColdFusion MX

The release of ColdFusion MX fundamentally changed the ColdFusion development landscape, especially with regards to G11N applications. I can't over emphasize that, which for me was a very strong reason to upgrade from ColdFusion 5. While you can perform a certain amount of G11N work with ColdFusion 5, it’s not as much fun, nor as elegant as ColdFusion MX. This point bears repeating: If you want to easily develop G11N applications, use ColdFusion MX.

Some of the more important "moves" that ColdFusion MX brings to the G11N dance:

  • The internal use of Unicode within ColdFusion MX standardizes and vastly expands the languages available for G11N—most of the known human languages. If that’s not globalized, I don’t know what is.
  • The addition of the important CJK (Chinese, Japanese, Korean) locales to the officially supported ColdFusion MX locales has made local CJK developers lives much easier (not to mention bringing other developers more straightforward access to those important markets).
  • The addition of character encoding options to several ColdFusion functions and tags to allow developers better encoding control: CFPROCESSINGDIRECTIVE, CFCONTENT, CFFILE, CFHEADER, CFHTTP, CFHTTPPARAM, CFMAIL, CFMAILPART tags and the SETENCODING, GETENCODING, TOBASE64, TOSTRING, URLDECODE, and URLENCODEDFORMAT functions have an option to control encoding.
  • Being based on Java, when you use ColdFusion MX, you can painlessly extend to non-official locales (such as Thailand where I live and work), as well as leverage the huge, often free, array of Java libraries, such as the IBM ICU4J library (one of my favorites because it provides extended I18N functionality, such as non-Gregorian calendars, holidays, transliteration, and so forth. It's the bee’s knees for I18N work).
  • ColdFusion components, which are the new ColdFusion application building blocks, enable transparent encapsulation of basic I18N functionality. CFCs make working with I18N Java libraries a breeze.

The initial release of ColdFusion MX, while impressive from a G11N standpoint, overlooked some functionality. Most notable was the lack of Unicode support for the popular Microsoft Access database. There was also no easy way to implement server-wide file or mail encoding schemes different from the default one (UTF-8). The recently released ColdFusion MX 6.1 version resolves these issues:

  • With the Microsoft Access Unicode driver, you can develop unicode-capable applications (you’ll see why this is important in a bit) using MS Access as a database. Note that this is completely separate from the ODBC-JDBC bridge middleware used for non-Unicode MS Access; you don’t have to install/run any of the ODBC services on your ColdFusion MX server to use Access for Unicode.
  • Macromedia added a new option to ColdFusion MX administrator under the server settings, mail sub-section: the Mail Charset Setting. With this setting, you enforce a server-wide character set for your e-mail. You can still set individual e-mails to any valid encoding using the CFMAIL charset attribute. For reasons I’ll elaborate on in the next section, I strongly urge you not to change this encoding.
  • You can force your ColdFusion MX server to use a different character encoding for HTTP from its default (UTF-8) by changing the defaultCharset value in cf_root/lib/neo-runtime.xml file:

    <var name='defaultCharset'><string>UTF-8</string></var>

    From UTF-8 to whatever encoding you wish to use server-wide. Note that the new encoding must be a valid Java encoding (for instance, Klingon won't work) and you must stop/restart your ColdFusion MX server service after changing this; once again, I urge you to stay with the default (of course, this applies to most applications). The new W3C document draft on i18n html authoring recommends using UTF-8/Unicode; read more about it in my blog.